package com.jie.user.service;

import com.jie.common.constant.RedisKey;
import com.jie.common.constant.StrConst;
import com.jie.common.util.BaseParameterHolder;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * @author jie
 * @version 1.0 2025-02-15
 */
@Service
@RequiredArgsConstructor
public class UserLogoutService {

    private final StringRedisTemplate stringRedisTemplate;

    public void logout() {
        // 一定是登录了的，网关会做登录校验
        String userId = BaseParameterHolder.getParameter(StrConst.USER_ID);
        String key = RedisKey.getRedisKey(RedisKey.LOGIN_USER_INFO + userId);
        stringRedisTemplate.delete(key);
    }
}
